const defaultAvatarUrl = '/images/defaultAvatar.png'
var app = getApp()
var IP = app.globalData.IP

Page({

  /**
   * 页面的初始数据
   */
  data: {

    menuList: [{
      name: '已接单',
      icon: '/static/image/icon-me-yjd.png',
      path: '/pages/order/orderlist/orderlist?status=2&active=2'
    }, {
      name: '已上门',
      icon: '/static/image/icon-me-wwc.png',
      path: '/pages/order/orderlist/orderlist?status=3&active=6'
    }, {
      name: '已完成',
      icon: '/static/image/icon-me-ywc.png',
      path: '/pages/order/orderlist/orderlist?status=4&active=3'
    }, {
      name: '已取消',
      icon: '/static/image/icon-me-yqx.png',
      path: '/pages/order/orderlist/orderlist?status=5&active=5'
    }],

    employee: '',
    employeeid: '160508',

  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.setStorageSync('employeeid', this.data.employeeid)

    if (options.employeeid | wx.getStorageSync('login')) {
      wx.setStorageSync('login', true)
      this.setData({
        employeeid: options.employeeid
      })
      this.getemployeeInfo()
    }
    this.getemployeeInfo()

  },


  getemployeeInfo() {
    wx.request({
      url: `http://${IP}:8080/employee/getemployeeinfo`,
      data: {
        employeeid: this.data.employeeid
      },
      success: res => {
        console.log(res)
        this.setData({
          employee: res.data
        })

      }
    })

  },
  //获取订单
  getOrders() {
    wx.navigateTo({
      url: '/pages/order/orderlist/orderlist',
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  // 退出登录
  logout: function () {

    wx.showModal({
      content: '确定退出登录吗？',
      cancelColor: '#666666', //666666
      confirmColor: '#666666',
      success(res) {
        if (res.confirm) {
          wx.reLaunch({
            url: '/pages/login/login'
          })
          console.log('用户点击确定')
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      },
      fail: function (res) {}, //接口调用失败的回调函数
      complete: function (res) {}, //接口调用结束的回调函数（调用成功、失败都会执行
    })

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {


  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})